package com.zofer.study.optional;

import com.zofer.study.optional.entity.Car;
import com.zofer.study.optional.entity.Insurance;
import com.zofer.study.optional.entity.Person;

import java.util.Optional;

public class OptionalTest01 {

    public static void main(String[] args) {
        test1();
    }

    /**
     * test1
     */
    public static void test1(){
        Optional<Person> optPerson = Optional.of(new Person());
        String name =
                optPerson.flatMap(Person::getCar)
                        .flatMap(Car::getInsurance)
                        .map(Insurance::getName).orElse("Unknown");
        System.out.println("====="+name);
    }
}
